var src = Array;

// item selection
$('li').click(function () {
  $(this).toggleClass('selected');121
  if ($('li.selected').length == 0)
    $('.select').removeClass('selected');
  else
    $('.select').addClass('selected');
  var list = new Array;
  var imgsrc = $(".selected").find("img").each(function () {
    list.push($(this).attr('src'));
  });
  src = list;
  console.log(src);
  counter();
});

// all item selection
$('.select').click(function () {
  if ($('li.selected').length == 0) {
    $('li').addClass('selected');
    $('.select').addClass('selected');
  }
  else {
    $('li').removeClass('selected');
    $('.select').removeClass('selected');
  }
  counter();
});

// number of selected items
function counter() {
  if ($('li.selected').length > 0)
    $('.send').addClass('selected');
  else
    $('.send').removeClass('selected');
  $('.send').attr('data-counter',$('li.selected').length);
}


function btnonclick() {
  if (src == null||src == "undefined"|src == " ") {
    alert("未选择文件");
  } else {
    $.ajax({
      url: "http://localhost:8080/userwork",
      type: "POST",
      dataType: "json",
      traditional: true,
      data: {
        "ids": src
      }
    });
    if(confirm("确定要删除吗？")){
      document.getElementById('form').setAttribute('action','../del');
    }else{
      alert("取消删除！")
    }
  }


}
